﻿USE Quaack
GO

CREATE TABLE profile(
	profileid					int IDENTITY(1,1)	NOT NULL,
	username					varchar(50)			NOT NULL,
	password					varchar(10) 		NOT NULL,
	profile						varchar(2048) 		NULL,
	email						varchar(50) 		NOT NULL,
	avatarlocation				varchar(50) 		NULL,
	mobilenumber				char(10) 			NULL,
	verificationpending			bit 				NOT NULL,
    verificationemail           varchar(50)         NULL,
	verificationpendingdatetime	datetime 			NULL,
	tempblocked					bit 				NOT NULL,
	tempblockeddatetime			datetime 			NULL,
	permblocked					bit 				NOT NULL,
	permblockeddatetime			datetime 			NULL,
	removed						bit 				NOT NULL,
	removeddatetime				datetime 			NULL,
	CONSTRAINT PK_profile PRIMARY KEY (profileid)
 )


CREATE TABLE message(
	messid				int IDENTITY(1,1)	NOT NULL,
	messdatetime 		datetime			NOT NULL,
	sender 				int					NOT NULL,
	parentmessid 		int					NULL,
	message 			varchar(160)		NOT NULL,
	removed 			bit					NOT NULL,
	removedby 			int					NULL,
	CONSTRAINT PK_message PRIMARY KEY (messid)
 )
 
/****** Object:  Table follower    Script Date: 05/23/2013 16:32:22 ******/
CREATE TABLE follower(
	followid		int IDENTITY(1,1)	NOT NULL,
	subject			int					NOT NULL,
	follower		int					NOT NULL,
	blocked			bit					NOT NULL,
	requestpending	bit					NOT NULL,
 CONSTRAINT PK_follower PRIMARY KEY (followid) 
 )
 
ALTER TABLE follower  ADD  CONSTRAINT FK_follower_profile_follower FOREIGN KEY(follower)
REFERENCES profile (profileid)

ALTER TABLE follower  ADD  CONSTRAINT FK_follower_profile_subject FOREIGN KEY(subject)
REFERENCES profile (profileid)

ALTER TABLE message  ADD  CONSTRAINT FK_message_message FOREIGN KEY(parentmessid)
REFERENCES message (messid)

ALTER TABLE message  ADD  CONSTRAINT FK_message_profile FOREIGN KEY(sender)
REFERENCES profile (profileid)

ALTER TABLE message  ADD  CONSTRAINT FK_message_profile_removedby FOREIGN KEY(removedby)
REFERENCES profile (profileid)